//
//  ExaminaStatisticsSecondCell.m
//  Coach_HaiGeEr
//
//  Created by liuchen on 2018/10/22.
//  Copyright © 2018年 海格尔. All rights reserved.
//

#import "ExaminaStatisticsSecondCell.h"
#import "ExaminaProgressView.h"
@interface ExaminaStatisticsSecondCell()
@property (nonatomic,weak) UILabel *totalNumLabel;
@property (nonatomic,weak) UILabel *passNumLabel;
@property (nonatomic,weak) ExaminaProgressView *progressView;
@end

@implementation ExaminaStatisticsSecondCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubView];
    }
    return self;
}

#pragma mark ==========创建视图==========
- (void)createSubView{
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    UILabel *totalNumLabel = [[UILabel alloc] init];
    totalNumLabel.textAlignment = NSTextAlignmentCenter;
    totalNumLabel.textColor = [UIColor colorWithHexString:@"#676fe9"];
    totalNumLabel.font = [UIFont systemFontOfSize:LoginFont+10];
    totalNumLabel.text = @"0";
    _totalNumLabel = totalNumLabel;
    [self.contentView addSubview:self.totalNumLabel];
    
    UILabel *totalLabel = [[UILabel alloc] init];
    totalLabel.text = @"考试人数";
    totalLabel.textAlignment = NSTextAlignmentCenter;
    totalLabel.font = [UIFont systemFontOfSize:LoginFont-5];
    totalLabel.textColor = [UIColor colorWithHexString:@"#666666"];
    [self.contentView addSubview:totalLabel];
    
    UILabel *passNumLabel = [[UILabel alloc] init];
    passNumLabel.text = @"0";
    passNumLabel.textAlignment = NSTextAlignmentCenter;
    passNumLabel.textColor = [UIColor colorWithHexString:@"#21d4a4"];
    passNumLabel.font = [UIFont systemFontOfSize:LoginFont+10];
    _passNumLabel = passNumLabel;
    [self.contentView addSubview:self.passNumLabel];
    
    UILabel *passLabel = [[UILabel alloc] init];
    passLabel.text = @"通过人数";
    passLabel.textAlignment = NSTextAlignmentCenter;
    passLabel.font = [UIFont systemFontOfSize:LoginFont-5];
    passLabel.textColor = [UIColor colorWithHexString:@"#666666"];
    [self.contentView addSubview:passLabel];
    
    UILabel *lineOne = [[UILabel alloc] init];
    lineOne.backgroundColor = [UIColor colorWithHexString:@"#eeeeee"];
    [self.contentView addSubview:lineOne];
    
    UILabel *lineTwo = [[UILabel alloc] init];
    lineTwo.backgroundColor = [UIColor colorWithHexString:@"#eeeeee"];
    [self.contentView addSubview:lineTwo];
    
    ExaminaProgressView *progressView = [[ExaminaProgressView alloc]initWithFrame:CGRectMake(0, 0, 300*SCALEUNIT, 300*SCALEUNIT)];
    progressView.arcFinishColor = [UIColor colorWithHexString:@"#6d8ff2"];
    progressView.arcUnfinishColor = [UIColor colorWithHexString:@"#6d8ff2"];
    progressView.arcBackColor = [UIColor colorWithHexString:@"#c5d2fa"];
    progressView.width = SCALEUNIT*50;
    _progressView = progressView;
    [self.contentView addSubview:self.progressView];
    
    //布局
    WS(ws);
    [self.totalNumLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(ws.contentView).with.offset(30*SCALEUNIT);
        make.right.mas_equalTo(ws.contentView.mas_centerX);
        make.top.mas_equalTo(ws.contentView).with.offset(27.5*SCALEUNIT);
        make.height.mas_equalTo(70*SCALEUNIT);
    }];
    [totalLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(ws.totalNumLabel.mas_bottom);
        make.height.mas_equalTo(50*SCALEUNIT);
        make.left.mas_equalTo(ws.contentView).with.offset(30*SCALEUNIT);
        make.right.mas_equalTo(ws.contentView.mas_centerX);
    }];
    [self.passNumLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(ws.contentView).with.offset(-30*SCALEUNIT);
        make.top.height.width.mas_equalTo(ws.totalNumLabel);
    }];
    [passLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(ws.passNumLabel.mas_bottom);
        make.height.mas_equalTo(50*SCALEUNIT);
        make.right.width.mas_equalTo(ws.passNumLabel);
    }];
    [lineOne mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(ws.contentView).with.offset(45*SCALEUNIT);
        make.centerX.mas_equalTo(ws.contentView);
        make.width.mas_equalTo(SCALEUNIT*2);
        make.height.mas_equalTo(100*SCALEUNIT);
    }];
    [lineTwo mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(ws);
        make.top.mas_equalTo(ws.contentView).with.offset(195*SCALEUNIT);
        make.height.mas_equalTo(SCALEUNIT*2);
        make.width.mas_equalTo(690*SCALEUNIT);
    }];
    [self.progressView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(ws);
        make.top.mas_equalTo(lineTwo.mas_bottom).with.offset(52.5*SCALEUNIT);
        make.size.mas_equalTo(CGSizeMake(300*SCALEUNIT, 300*SCALEUNIT));
    }];
}

#pragma mark ==========填充数据==========
- (void)setPassDic:(NSDictionary *)passDic{
    _passDic = passDic;
    self.totalNumLabel.text = [NSString stringWithFormat:@"%@",[_passDic objectForKey:@"examCount"]];
    self.passNumLabel.text = [NSString stringWithFormat:@"%@",[_passDic objectForKey:@"examThroughCount"]];
    self.progressView.percent = [[_passDic objectForKey:@"examCount"] integerValue]==0?0:[[_passDic objectForKey:@"examThroughCount"] floatValue]/[[_passDic objectForKey:@"examCount"] floatValue];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
